
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>内核调度线程 idle · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-katex/katex.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-emphasize/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-tomorrow.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="part3.html" />
    
    
    <link rel="prev" href="part1.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../chapter0/introduction.html">
            
                <a href="../chapter0/introduction.html">
            
                    
                    第零章：实验环境说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../chapter1/introduction.html">
            
                <a href="../chapter1/introduction.html">
            
                    
                    第一章：独立式可执行程序
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../chapter1/part1.html">
            
                <a href="../chapter1/part1.html">
            
                    
                    [安装 nightly rust]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../chapter1/part2.html">
            
                <a href="../chapter1/part2.html">
            
                    
                    使用包管理器 cargo 创建 rust binary 项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../chapter1/part3.html">
            
                <a href="../chapter1/part3.html">
            
                    
                    移除标准库依赖
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../chapter1/part4.html">
            
                <a href="../chapter1/part4.html">
            
                    
                    [移除 runtime 依赖]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../chapter1/part5.html">
            
                <a href="../chapter1/part5.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../chapter2/introduction.html">
            
                <a href="../chapter2/introduction.html">
            
                    
                    第二章：最小化内核
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../chapter2/part1.html">
            
                <a href="../chapter2/part1.html">
            
                    
                    使用目标三元组描述目标平台
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../chapter2/part2.html">
            
                <a href="../chapter2/part2.html">
            
                    
                    编译、生成内核镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../chapter2/part3.html">
            
                <a href="../chapter2/part3.html">
            
                    
                    使用链接脚本指定内存布局
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../chapter2/part4.html">
            
                <a href="../chapter2/part4.html">
            
                    
                    [重写程序入口点 -start]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../chapter2/part5.html">
            
                <a href="../chapter2/part5.html">
            
                    
                    [使用 Qemu 运行内核]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../chapter2/part6.html">
            
                <a href="../chapter2/part6.html">
            
                    
                    封装 SBI 接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../chapter2/part7.html">
            
                <a href="../chapter2/part7.html">
            
                    
                    [实现格式化输出]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../chapter2/part8.html">
            
                <a href="../chapter2/part8.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../chapter3/introduction.html">
            
                <a href="../chapter3/introduction.html">
            
                    
                    第三章：中断
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../chapter3/part1.html">
            
                <a href="../chapter3/part1.html">
            
                    
                    rv64 中断介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../chapter3/part2.html">
            
                <a href="../chapter3/part2.html">
            
                    
                    [手动触发断点中断]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../chapter3/part3.html">
            
                <a href="../chapter3/part3.html">
            
                    
                    程序运行上下文环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../chapter3/part4.html">
            
                <a href="../chapter3/part4.html">
            
                    
                    [实现上下文环境保存与恢复]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../chapter3/part5.html">
            
                <a href="../chapter3/part5.html">
            
                    
                    [时钟中断]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../chapter3/part6.html">
            
                <a href="../chapter3/part6.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../chapter4/introduction.html">
            
                <a href="../chapter4/introduction.html">
            
                    
                    第四章：内存管理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../chapter4/part1.html">
            
                <a href="../chapter4/part1.html">
            
                    
                    [物理内存探测与管理]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../chapter4/part2.html">
            
                <a href="../chapter4/part2.html">
            
                    
                    [动态内存分配]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../chapter4/part3.html">
            
                <a href="../chapter4/part3.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../chapter5/introduction.html">
            
                <a href="../chapter5/introduction.html">
            
                    
                    第五章：内存虚拟化
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../chapter5/part1.html">
            
                <a href="../chapter5/part1.html">
            
                    
                    页表：从虚拟内存到物理内存
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../chapter5/part2.html">
            
                <a href="../chapter5/part2.html">
            
                    
                    [内核初始映射]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../chapter5/part3.html">
            
                <a href="../chapter5/part3.html">
            
                    
                    内核重映射
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../chapter5/part4.html">
            
                <a href="../chapter5/part4.html">
            
                    
                    内核重映射实现之一：页表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../chapter5/part5.html">
            
                <a href="../chapter5/part5.html">
            
                    
                    内核重映射实现之二：MemorySet
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="../chapter5/part6.html">
            
                <a href="../chapter5/part6.html">
            
                    
                    [内核重映射实现之三：完结]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" data-path="../chapter5/part7.html">
            
                <a href="../chapter5/part7.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../chapter6/introduction.html">
            
                <a href="../chapter6/introduction.html">
            
                    
                    第六章：内核线程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../chapter6/part1.html">
            
                <a href="../chapter6/part1.html">
            
                    
                    线程状态与保存
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../chapter6/part2.html">
            
                <a href="../chapter6/part2.html">
            
                    
                    线程切换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../chapter6/part3.html">
            
                <a href="../chapter6/part3.html">
            
                    
                    内核线程初始化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../chapter6/part4.html">
            
                <a href="../chapter6/part4.html">
            
                    
                    [内核线程创建与切换测试]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="../chapter6/part5.html">
            
                <a href="../chapter6/part5.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="introduction.html">
            
                <a href="introduction.html">
            
                    
                    第七章：线程调度
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="part1.html">
            
                <a href="part1.html">
            
                    
                    线程池与线程管理
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.9.2" data-path="part2.html">
            
                <a href="part2.html">
            
                    
                    内核调度线程 idle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="part3.html">
            
                <a href="part3.html">
            
                    
                    线程调度之 Round Robin 算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" data-path="part4.html">
            
                <a href="part4.html">
            
                    
                    [线程调度测试]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.5" data-path="part5.html">
            
                <a href="part5.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../chapter8/introduction.html">
            
                <a href="../chapter8/introduction.html">
            
                    
                    第八章：进程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../chapter8/part1.html">
            
                <a href="../chapter8/part1.html">
            
                    
                    [编写用户程序]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../chapter8/part1_1.html">
            
                <a href="../chapter8/part1_1.html">
            
                    
                    合并内核与应用程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../chapter8/part2.html">
            
                <a href="../chapter8/part2.html">
            
                    
                    在内核中实现系统调用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../chapter8/part3.html">
            
                <a href="../chapter8/part3.html">
            
                    
                    创建虚拟内存空间
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../chapter8/part4.html">
            
                <a href="../chapter8/part4.html">
            
                    
                    [创建进程]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" data-path="../chapter8/part5.html">
            
                <a href="../chapter8/part5.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../chapter9/introduction.html">
            
                <a href="../chapter9/introduction.html">
            
                    
                    第九章：文件系统
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../chapter9/part1.html">
            
                <a href="../chapter9/part1.html">
            
                    
                    [使用文件系统]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../chapter9/part2.html">
            
                <a href="../chapter9/part2.html">
            
                    
                    [实现记事本]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../chapter9/part3.html">
            
                <a href="../chapter9/part3.html">
            
                    
                    [实现终端]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="../chapter9/part4.html">
            
                <a href="../chapter9/part4.html">
            
                    
                    [文件读写]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="../chapter9/part5.html">
            
                <a href="../chapter9/part5.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../chapter10/introduction.html">
            
                <a href="../chapter10/introduction.html">
            
                    
                    第十章：同步互斥
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../exercise/introduction.html">
            
                <a href="../exercise/introduction.html">
            
                    
                    练习题
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../exercise/part1.html">
            
                <a href="../exercise/part1.html">
            
                    
                    1. 中断异常
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../exercise/part2.html">
            
                <a href="../exercise/part2.html">
            
                    
                    2. 物理内存管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" data-path="../exercise/part3.html">
            
                <a href="../exercise/part3.html">
            
                    
                    3. 虚拟内存管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.4" data-path="../exercise/part4.html">
            
                <a href="../exercise/part4.html">
            
                    
                    4. 线程管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.5" data-path="../exercise/part5.html">
            
                <a href="../exercise/part5.html">
            
                    
                    5. 用户进程（+ 虚拟内存管理 + 线程管理）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.6" data-path="../exercise/part6.html">
            
                <a href="../exercise/part6.html">
            
                    
                    6. CPU 调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.7" data-path="../exercise/part7.html">
            
                <a href="../exercise/part7.html">
            
                    
                    7. 同步互斥
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.8" data-path="../exercise/part8.html">
            
                <a href="../exercise/part8.html">
            
                    
                    8. 文件系统
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../appendix/introduction.html">
            
                <a href="../appendix/introduction.html">
            
                    
                    附录
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.14.1" data-path="../appendix/inline_asm.html">
            
                <a href="../appendix/inline_asm.html">
            
                    
                    内联汇编
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.2" data-path="../appendix/install_rust.html">
            
                <a href="../appendix/install_rust.html">
            
                    
                    安装 rust
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >内核调度线程 idle</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="&#x5185;&#x6838;&#x8C03;&#x5EA6;&#x7EBF;&#x7A0B;-idle">&#x5185;&#x6838;&#x8C03;&#x5EA6;&#x7EBF;&#x7A0B; idle</h2>
<ul>
<li><a href="https://github.com/rcore-os/rCore_tutorial/tree/ch7-pa4" target="_blank">&#x4EE3;&#x7801;</a></li>
</ul>
<h3 id="&#x8C03;&#x5EA6;&#x7EBF;&#x7A0B;-idle-&#x7684;&#x4F5C;&#x7528;">&#x8C03;&#x5EA6;&#x7EBF;&#x7A0B; idle &#x7684;&#x4F5C;&#x7528;</h3>
<p>&#x8C03;&#x5EA6;&#x7EBF;&#x7A0B; idle &#x662F;&#x4E00;&#x4E2A;&#x5185;&#x6838;&#x7EBF;&#x7A0B;&#xFF0C;&#x5B83;&#x7684;&#x4F5C;&#x7528;&#x662F;</p>
<ul>
<li>&#x5F53;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x5176;&#x4ED6;&#x7EBF;&#x7A0B;&#x65F6;&#xFF0C;idle &#x7EBF;&#x7A0B;&#x8FD0;&#x884C;&#x5E76;&#x5FAA;&#x73AF;&#x68C0;&#x6D4B;&#x662F;&#x5426;&#x80FD;&#x4ECE;&#x7EBF;&#x7A0B;&#x6C60;&#x4E2D;&#x627E;&#x5230;&#x4E00;&#x4E2A;&#x53EF;&#x8FD0;&#x884C;&#x7684;&#x7EBF;&#x7A0B;&#xFF0C;&#x5982;&#x679C;&#x80FD;&#x627E;&#x5230;&#x7684;&#x8BDD;&#x5C31;&#x5207;&#x6362;&#x8FC7;&#x53BB;&#xFF1B;</li>
<li>&#x5F53;&#x67D0;&#x4E2A;&#x7EBF;&#x7A0B;&#x88AB;&#x8C03;&#x5EA6;&#x5668;&#x51B3;&#x5B9A;&#x4EA4;&#x51FA; CPU &#x8D44;&#x6E90;&#x5E76;&#x5207;&#x6362;&#x51FA;&#x53BB;&#xFF08;&#x5982;&#x5B83;&#x5DF2;&#x8FD0;&#x884C;&#x4E86;&#x5F88;&#x4E45;&#xFF0C;&#x6216;&#x5B83;&#x8FD0;&#x884C;&#x7ED3;&#x675F;&#xFF09;&#x65F6;&#xFF0C;&#x5E76;&#x4E0D;&#x662F;&#x76F4;&#x63A5;&#x5207;&#x6362;&#x5230;&#x4E0B;&#x4E00;&#x4E2A;&#x7EBF;&#x7A0B;&#xFF0C;&#x800C;&#x662F;&#x5148;&#x5207;&#x6362;&#x56DE; idle &#x7EBF;&#x7A0B;&#xFF0C;&#x968F;&#x540E;&#x540C;&#x6837;&#x8FDB;&#x884C;&#x4E0A;&#x8FF0;&#x7684;&#x5FAA;&#x73AF;&#x5C1D;&#x8BD5;&#x4ECE;&#x7EBF;&#x7A0B;&#x6C60;&#x4E2D;&#x627E;&#x5230;&#x4E00;&#x4E2A;&#x53EF;&#x8FD0;&#x884C;&#x7EBF;&#x7A0B;&#x5E76;&#x5207;&#x6362;&#x8FC7;&#x53BB;&#x3002;</li>
</ul>
<h3 id="&#x5B9E;&#x73B0;&#x8C03;&#x5EA6;&#x7EBF;&#x7A0B;-idle-&#x7684;&#x5C01;&#x88C5;&#x51C6;&#x5907;">&#x5B9E;&#x73B0;&#x8C03;&#x5EA6;&#x7EBF;&#x7A0B; idle &#x7684;&#x5C01;&#x88C5;&#x51C6;&#x5907;</h3>
<h4 id="processorinner">ProcessorInner</h4>
<p>&#x5728;&#x4ECB;&#x7ECD; idle &#x7EBF;&#x7A0B;&#x7684;&#x5B9E;&#x73B0;&#x4E4B;&#x524D;&#xFF0C;&#x6211;&#x4EEC;&#x5148;&#x8981;&#x5C06; idle &#x7EBF;&#x7A0B;&#x6240;&#x9700;&#x7684;&#x5404;&#x79CD;&#x8D44;&#x6E90;&#x5C01;&#x88C5;&#x5728;&#x4E00;&#x8D77;&#xFF1A;</p>
<pre class="language-"><code class="lang-rust"><span class="token comment">// src/process/processor.rs</span>
<span class="token comment">// &#x8C03;&#x5EA6;&#x5355;&#x5143; Processor &#x7684;&#x5185;&#x5BB9;</span>
<span class="token keyword">pub</span> <span class="token keyword">struct</span> <span class="token type-definition class-name">ProcessorInner</span> <span class="token punctuation">{</span>
    <span class="token comment">// &#x7EBF;&#x7A0B;&#x6C60;</span>
    pool<span class="token punctuation">:</span> <span class="token class-name">Box</span><span class="token operator">&lt;</span><span class="token class-name">ThreadPool</span><span class="token operator">&gt;</span><span class="token punctuation">,</span>
    <span class="token comment">// idle &#x7EBF;&#x7A0B;</span>
    idle<span class="token punctuation">:</span> <span class="token class-name">Box</span><span class="token operator">&lt;</span><span class="token class-name">Thread</span><span class="token operator">&gt;</span><span class="token punctuation">,</span>
    <span class="token comment">// &#x5F53;&#x524D;&#x6B63;&#x5728;&#x8FD0;&#x884C;&#x7684;&#x7EBF;&#x7A0B;</span>
    current<span class="token punctuation">:</span> <span class="token class-name">Option</span><span class="token operator">&lt;</span><span class="token punctuation">(</span><span class="token class-name">Tid</span><span class="token punctuation">,</span> <span class="token class-name">Box</span><span class="token operator">&lt;</span><span class="token class-name">Thread</span><span class="token operator">&gt;</span><span class="token punctuation">)</span><span class="token operator">&gt;</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x6211;&#x4EEC;&#x9700;&#x8981; <code>ProcessorInner</code> &#x80FD;&#x591F;&#x88AB;&#x5168;&#x5C40;&#x8BBF;&#x95EE;&#xFF0C;&#x56E0;&#x4E3A;&#x542F;&#x52A8;&#x7EBF;&#x7A0B;&#x548C;&#x8C03;&#x5EA6;&#x7EBF;&#x7A0B; idle &#x4EE5;&#x53CA; idle &#x6240;&#x7BA1;&#x7406;&#x7684;&#x7EBF;&#x7A0B;&#x90FD;&#x4F1A;&#x8BBF;&#x95EE;&#x5B83;&#x3002;&#x5728;&#x5904;&#x7406;&#x8FD9;&#x79CD;&#x6570;&#x636E;&#x7684;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x683C;&#x5916;&#x5C0F;&#x5FC3;&#x3002;</p>
<h4 id="&#x3000;-processor">&#x3000; Processor</h4>
<p>&#x6211;&#x4EEC;&#x5728;&#x7B2C;&#x56DB;&#x7AE0;&#x5185;&#x5B58;&#x7BA1;&#x7406;&#x4E2D;&#x4ECB;&#x7ECD;&#x5185;&#x5B58;&#x5206;&#x914D;&#x5668;&#x65F6;&#x4E5F;&#x66FE;&#x9047;&#x5230;&#x8FC7;&#x540C;&#x6837;&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x6211;&#x4EEC;&#x60F3;&#x8981;&#x5B9E;&#x73B0; <code>static mut</code> &#x7684;&#x6548;&#x679C;&#x4F7F;&#x5F97;&#x591A;&#x4E2A;&#x7EBF;&#x7A0B;&#x5747;&#x53EF;&#x4FEE;&#x6539;&#xFF0C;&#x4F46;&#x53C8;&#x8981;&#x6C42;&#x662F;<strong>&#x7EBF;&#x7A0B;&#x5B89;&#x5168;</strong>&#x7684;&#x3002;&#x5F53;&#x65F6;&#x6211;&#x4EEC;&#x7684;&#x5904;&#x7406;&#x65B9;&#x6CD5;&#x662F;&#x4F7F;&#x7528; <code>spin::Mutex</code> &#x4E0A;&#x4E00;&#x628A;&#x9501;&#x3002;&#x8FD9;&#x91CC;&#x867D;&#x7136;&#x4E5F;&#x53EF;&#x4EE5;&#xFF0C;&#x4F46;&#x662F;&#x6709;&#x4E9B;&#x5927;&#x6750;&#x5C0F;&#x7528;&#x4E86;&#x3002;&#x56E0;&#x4E3A;<em>&#x8FD9;&#x91CC;&#x7684;&#x60C5;&#x51B5;&#x66F4;&#x4E3A;&#x7B80;&#x5355;&#x4E00;&#x4E9B;</em>&#xFF0C;&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x4F7F;&#x7528;&#x4E0B;&#x9762;&#x7684;&#x65B9;&#x6CD5;&#x5C31;&#x8DB3;&#x591F;&#x4E86;&#x3002;</p>
<blockquote>
<p><strong>[info]&#x4E3A;&#x4F55;&#x8BF4;&#x201C;&#x8FD9;&#x91CC;&#x7684;&#x60C5;&#x51B5;&#x66F4;&#x7B80;&#x5355;&#x4E00;&#x4E9B;&#x201D;&#xFF1F;</strong></p>
<p>&#x5728;&#x5904;&#x7406;<code>Processor</code>&#x7ED3;&#x6784;&#x4F53;&#x65F6;&#xFF0C;&#x662F;&#x5173;&#x95ED; CPU &#x4E2D;&#x65AD;&#x7684;&#x3002;???</p>
</blockquote>
<pre class="language-"><code class="lang-rust"><span class="token comment">// src/process/processor.rs</span>
<span class="token keyword">pub</span> <span class="token keyword">struct</span> <span class="token type-definition class-name">Processor</span> <span class="token punctuation">{</span>
    inner<span class="token punctuation">:</span> <span class="token class-name">UnsafeCell</span><span class="token operator">&lt;</span><span class="token class-name">Option</span><span class="token operator">&lt;</span><span class="token class-name">ProcessorInner</span><span class="token operator">&gt;&gt;</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span>
<span class="token keyword">unsafe</span> <span class="token keyword">impl</span> <span class="token class-name">Sync</span> <span class="token keyword">for</span> <span class="token class-name">Processor</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>

<span class="token comment">// src/process/mod.rs</span>
<span class="token keyword">use</span> <span class="token namespace">processor<span class="token punctuation">::</span></span><span class="token class-name">Processor</span><span class="token punctuation">;</span>
<span class="token keyword">static</span> <span class="token constant">CPU</span><span class="token punctuation">:</span> <span class="token class-name">Processor</span> <span class="token operator">=</span> <span class="token class-name">Processor</span><span class="token punctuation">::</span><span class="token function">new</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<p>&#x8FD9;&#x91CC;&#x9762;&#x6211;&#x4EEC;&#x5C06;&#x5B9E;&#x4F8B; <code>CPU</code> &#x58F0;&#x660E;&#x4E3A; <code>static</code> &#x3002;&#x7F16;&#x8BD1;&#x5668;&#x8BA4;&#x4E3A; <code>Processor</code> &#x4E0D;&#x4E00;&#x5B9A;&#x80FD;&#x591F;&#x5B89;&#x5168;&#x5730;&#x5141;&#x8BB8;&#x591A;&#x7EBF;&#x7A0B;&#x8BBF;&#x95EE;&#xFF0C;&#x4E8E;&#x662F;&#x58F0;&#x660E;&#x4E00;&#x4E2A; <code>static</code> &#x5B9E;&#x4F8B;&#x662F;&#x4F1A;&#x62A5;&#x9519;&#x7684;&#x3002;</p>
<p>&#x56E0;&#x6B64;&#x6211;&#x4EEC;&#x4E3A; <code>Processor</code> &#x5B9E;&#x73B0; <code>Sync Trait</code> &#x544A;&#x8BC9;&#x7F16;&#x8BD1;&#x5668;&#x8FD9;&#x4E2A;&#x7ED3;&#x6784;&#x4F53;&#x53EF;&#x4EE5;&#x5B89;&#x5168;&#x7684;&#x5728;&#x591A;&#x4E2A;&#x7EBF;&#x7A0B;&#x4E2D;&#x62E5;&#x6709;&#x5176;&#x503C;&#x7684;&#x5F15;&#x7528;&#xFF0C;&#x4ECE;&#x800C;&#x5141;&#x8BB8;&#x591A;&#x7EBF;&#x7A0B;&#x8BBF;&#x95EE;&#x3002;&#x4F60;&#x5E76;&#x4E0D;&#x9700;&#x8981;&#x5B9E;&#x73B0;&#x4EFB;&#x4F55;&#x65B9;&#x6CD5;&#xFF0C;&#x56E0;&#x4E3A;&#x8FD9;&#x53EA;&#x662F;&#x4E00;&#x4E2A;&#x6807;&#x8BB0;&#x3002;&#x5B83;&#x662F; <code>unsafe</code> &#x7684;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x7F16;&#x8BD1;&#x5668;&#x8BA4;&#x4E3A;&#x5B83;&#x4E5F;&#x8BB8;&#x4E0D;&#x662F;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#xFF0C;&#x4F60;&#x5374;&#x4FE1;&#x8A93;&#x65E6;&#x65E6;&#x5730;&#x5411;&#x5B83;&#x4FDD;&#x8BC1;&#x4E86;&#x8FD9;&#x4E00;&#x70B9;&#xFF0C;&#x90A3;&#x4E48;&#x5982;&#x679C;&#x51FA;&#x4E86;&#x95EE;&#x9898;&#x7684;&#x8BDD;&#x5C31;&#x53EA;&#x80FD;&#x9760;&#x4F60;&#x81EA;&#x5DF1;&#x89E3;&#x51B3;&#x4E86;&#x3002;</p>
<p>&#x90A3;&#x4E48; <code>mut</code> &#x53C8;&#x5728;&#x54EA;&#x91CC;&#xFF1F;&#x6CE8;&#x610F;&#x5230;&#x6211;&#x4EEC;&#x4F7F;&#x7528; <code>UnsafeCell<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>T</span><span class="token punctuation">&gt;</span></span></code> &#x6765;&#x5BF9; <code>ProcessInner</code> &#x8FDB;&#x884C;&#x4E86;&#x5305;&#x88F9;&#xFF0C;<code>UnsafeCell<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>T</span><span class="token punctuation">&gt;</span></span></code> &#x63D0;&#x4F9B;&#x4E86;<strong>&#x5185;&#x90E8;&#x53EF;&#x53D8;&#x6027; (Interior mutability)</strong>&#xFF0C;&#x5373;&#x4F7F;&#x5B83;&#x672C;&#x8EAB;&#x4E0D;&#x662F; <code>mut</code> &#x7684;&#xFF0C;&#x4ECD;&#x80FD;&#x591F;&#x4FEE;&#x6539;&#x5185;&#x90E8;&#x6240;&#x5305;&#x88F9;&#x7684;&#x503C;&#x3002;&#x53E6;&#x5916;&#x8FD8;&#x6709;&#x5F88;&#x591A;&#x79CD;&#x65B9;&#x5F0F;&#x53EF;&#x4EE5;&#x63D0;&#x4F9B;&#x5185;&#x90E8;&#x53EF;&#x53D8;&#x6027;&#x3002;</p>
<p>&#x63A5;&#x4E0B;&#x6765;&#x9996;&#x5148;&#x6765;&#x770B; <code>Processor</code> &#x7684;&#x51E0;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x65B9;&#x6CD5;&#xFF1A;</p>
<pre class="language-"><code class="lang-rust"><span class="token comment">// src/process/processor.rs</span>
<span class="token keyword">impl</span> <span class="token class-name">Processor</span> <span class="token punctuation">{</span>
    <span class="token comment">// &#x65B0;&#x5EFA;&#x4E00;&#x4E2A;&#x7A7A;&#x7684; Processor</span>
    <span class="token keyword">pub</span> <span class="token keyword">const</span> <span class="token keyword">fn</span> <span class="token function-definition function">new</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">-&gt;</span> <span class="token class-name">Processor</span> <span class="token punctuation">{</span>
        <span class="token class-name">Processor</span> <span class="token punctuation">{</span>  inner<span class="token punctuation">:</span> <span class="token class-name">UnsafeCell</span><span class="token punctuation">::</span><span class="token function">new</span><span class="token punctuation">(</span><span class="token class-name">None</span><span class="token punctuation">)</span><span class="token punctuation">,</span>  <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
    <span class="token comment">// &#x4F20;&#x5165; idle &#x7EBF;&#x7A0B;&#xFF0C;&#x4EE5;&#x53CA;&#x7EBF;&#x7A0B;&#x6C60;&#x8FDB;&#x884C;&#x521D;&#x59CB;&#x5316;</span>
    <span class="token keyword">pub</span> <span class="token keyword">fn</span> <span class="token function-definition function">init</span><span class="token punctuation">(</span><span class="token operator">&amp;</span><span class="token keyword">self</span><span class="token punctuation">,</span> idle<span class="token punctuation">:</span> <span class="token class-name">Box</span><span class="token operator">&lt;</span><span class="token class-name">Thread</span><span class="token operator">&gt;</span><span class="token punctuation">,</span> pool<span class="token punctuation">:</span> <span class="token class-name">Box</span><span class="token operator">&lt;</span><span class="token class-name">ThreadPool</span><span class="token operator">&gt;</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">unsafe</span> <span class="token punctuation">{</span>
            <span class="token operator">*</span><span class="token keyword">self</span><span class="token punctuation">.</span>inner<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token class-name">Some</span><span class="token punctuation">(</span>
                <span class="token class-name">ProcessorInner</span> <span class="token punctuation">{</span>
                    pool<span class="token punctuation">,</span>
                    idle<span class="token punctuation">,</span>
                    current<span class="token punctuation">:</span> <span class="token class-name">None</span><span class="token punctuation">,</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
    <span class="token comment">// &#x5185;&#x90E8;&#x53EF;&#x53D8;&#x6027;&#xFF1A;&#x83B7;&#x53D6;&#x5305;&#x88F9;&#x7684;&#x503C;&#x7684;&#x53EF;&#x53D8;&#x5F15;&#x7528;</span>
    <span class="token keyword">fn</span> <span class="token function-definition function">inner</span><span class="token punctuation">(</span><span class="token operator">&amp;</span><span class="token keyword">self</span><span class="token punctuation">)</span> <span class="token punctuation">-&gt;</span> <span class="token operator">&amp;</span><span class="token keyword">mut</span> <span class="token class-name">ProcessorInner</span> <span class="token punctuation">{</span>
        <span class="token keyword">unsafe</span> <span class="token punctuation">{</span> <span class="token operator">&amp;</span><span class="token keyword">mut</span> <span class="token operator">*</span><span class="token keyword">self</span><span class="token punctuation">.</span>inner<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">}</span>
            <span class="token punctuation">.</span><span class="token function">as_mut</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">expect</span><span class="token punctuation">(</span><span class="token string">&quot;Processor is not initialized!&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
    <span class="token comment">// &#x901A;&#x8FC7;&#x7EBF;&#x7A0B;&#x6C60;&#x65B0;&#x589E;&#x7EBF;&#x7A0B;</span>
    <span class="token keyword">pub</span> <span class="token keyword">fn</span> <span class="token function-definition function">add_thread</span><span class="token punctuation">(</span><span class="token operator">&amp;</span><span class="token keyword">self</span><span class="token punctuation">,</span> thread<span class="token punctuation">:</span> <span class="token class-name">Box</span><span class="token operator">&lt;</span><span class="token class-name">Thread</span><span class="token operator">&gt;</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">self</span><span class="token punctuation">.</span><span class="token function">inner</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span>pool<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>thread<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>idle &#x7EBF;&#x7A0B;&#x4E0E;&#x5176;&#x4ED6;&#x5B83;&#x6240;&#x7BA1;&#x7406;&#x7684;&#x7EBF;&#x7A0B;&#x76F8;&#x6BD4;&#x6709;&#x4E00;&#x70B9;&#x4E0D;&#x540C;&#x4E4B;&#x5904;&#xFF1A;&#x5B83;&#x4E0D;&#x5E0C;&#x671B;&#x88AB;&#x5F02;&#x6B65;&#x4E2D;&#x65AD;&#x6253;&#x65AD;&#xFF01;&#x5426;&#x5219;&#x4F1A;&#x4EA7;&#x751F;&#x5F88;&#x5FAE;&#x5999;&#x7684;&#x9519;&#x8BEF;&#x3002;</p>
<p>&#x5C24;&#x5176;&#x662F;&#x65F6;&#x949F;&#x4E2D;&#x65AD;&#xFF0C;&#x8BBE;&#x60F3;&#x4E00;&#x4E2A;&#x7EBF;&#x7A0B;&#x65F6;&#x95F4;&#x8017;&#x5C3D;&#xFF0C;&#x88AB;&#x5207;&#x6362;&#x5230; idle &#x7EBF;&#x7A0B;&#x8FDB;&#x884C;&#x8C03;&#x5EA6;&#xFF0C;&#x7ED3;&#x679C;&#x8FD8;&#x6CA1;&#x5B8C;&#x6210;&#x8C03;&#x5EA6;&#x53C8;&#x8FDB;&#x5165;&#x65F6;&#x949F;&#x4E2D;&#x65AD;&#x5F00;&#x59CB;&#x8C03;&#x5EA6;&#x3002;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x60F3;&#x5FC5;&#x5F88;&#x96BE;&#x5904;&#x7406;&#x3002;</p>
<p>&#x4E3A;&#x6B64;&#xFF0C;&#x5728; idle &#x7EBF;&#x7A0B;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x8981;&#x5173;&#x95ED;&#x6240;&#x6709;&#x7684;&#x4E2D;&#x65AD;&#xFF0C;&#x540C;&#x65F6;&#x5728;&#x5728;&#x9002;&#x5F53;&#x7684;&#x65F6;&#x673A;&#x6062;&#x590D;&#x4E2D;&#x65AD;&#x3002;&#x4E0B;&#x9762;&#x7ED9;&#x51FA;&#x51E0;&#x4E2A;&#x51FD;&#x6570;&#xFF1A;</p>
<pre class="language-"><code class="lang-rust"><span class="token comment">// src/interrupt.rs</span>

<span class="token attribute attr-name">#[inline(always)]</span>
<span class="token keyword">pub</span> <span class="token keyword">fn</span> <span class="token function-definition function">disable_and_store</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">-&gt;</span> <span class="token keyword">usize</span> <span class="token punctuation">{</span>
    <span class="token keyword">let</span> sstatus<span class="token punctuation">:</span> <span class="token keyword">usize</span><span class="token punctuation">;</span>
    <span class="token keyword">unsafe</span> <span class="token punctuation">{</span>
        <span class="token comment">// clear sstatus &#x7684; SIE &#x6807;&#x5FD7;&#x4F4D;&#x7981;&#x7528;&#x5F02;&#x6B65;&#x4E2D;&#x65AD;</span>
        <span class="token comment">// &#x8FD4;&#x56DE; clear &#x4E4B;&#x524D;&#x7684; sstatus &#x72B6;&#x6001;</span>
        <span class="token macro property">asm!</span><span class="token punctuation">(</span><span class="token string">&quot;csrci sstatus, 1 &lt;&lt; 1&quot;</span> <span class="token punctuation">:</span> <span class="token string">&quot;=r&quot;</span><span class="token punctuation">(</span>sstatus<span class="token punctuation">)</span> <span class="token punctuation">::</span><span class="token punctuation">:</span> <span class="token string">&quot;volatile&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    sstatus
<span class="token punctuation">}</span>

<span class="token attribute attr-name">#[inline(always)]</span>
<span class="token keyword">pub</span> <span class="token keyword">fn</span> <span class="token function-definition function">restore</span><span class="token punctuation">(</span>flags<span class="token punctuation">:</span> <span class="token keyword">usize</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">unsafe</span> <span class="token punctuation">{</span>
        <span class="token comment">// &#x5C06; sstatus &#x8BBE;&#x7F6E;&#x4E3A; flags &#x7684;&#x503C;</span>
        <span class="token macro property">asm!</span><span class="token punctuation">(</span><span class="token string">&quot;csrs sstatus, $0&quot;</span> <span class="token punctuation">::</span> <span class="token string">&quot;r&quot;</span><span class="token punctuation">(</span>flags<span class="token punctuation">)</span> <span class="token punctuation">::</span> <span class="token string">&quot;volatile&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token attribute attr-name">#[inline(always)]</span>
<span class="token keyword">pub</span> <span class="token keyword">fn</span> <span class="token function-definition function">enable_and_wfi</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">unsafe</span> <span class="token punctuation">{</span>
        <span class="token comment">// set sstatus &#x7684; SIE &#x6807;&#x5FD7;&#x4F4D;&#x542F;&#x7528;&#x5F02;&#x6B65;&#x4E2D;&#x65AD;</span>
        <span class="token comment">// &#x5E76;&#x901A;&#x8FC7; wfi &#x6307;&#x4EE4;&#x7B49;&#x5F85;&#x4E0B;&#x4E00;&#x6B21;&#x5F02;&#x6B65;&#x4E2D;&#x65AD;&#x7684;&#x5230;&#x6765;</span>
        <span class="token macro property">asm!</span><span class="token punctuation">(</span><span class="token string">&quot;csrsi sstatus, 1 &lt;&lt; 1; wfi&quot;</span> <span class="token punctuation">::</span><span class="token punctuation">::</span> <span class="token string">&quot;volatile&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="&#x6838;&#x5FC3;&#x51FD;&#x6570;-idlemain">&#x6838;&#x5FC3;&#x51FD;&#x6570; idle_main</h3>
<p>&#x63A5;&#x4E0B;&#x6765;&#xFF0C;&#x6211;&#x4EEC;&#x6765;&#x770B; idle &#x7EBF;&#x7A0B;&#x7684;&#x6700;&#x6838;&#x5FC3;&#x51FD;&#x6570;&#xFF0C;&#x4E5F;&#x662F;&#x5176;&#x5165;&#x53E3;&#x70B9;&#xFF1A;</p>
<pre class="language-"><code class="lang-rust"><span class="token comment">// src/process/processor.rs</span>

<span class="token keyword">impl</span> <span class="token class-name">Processor</span> <span class="token punctuation">{</span>
    <span class="token keyword">pub</span> <span class="token keyword">fn</span> <span class="token function-definition function">idle_main</span><span class="token punctuation">(</span><span class="token operator">&amp;</span><span class="token keyword">self</span><span class="token punctuation">)</span> <span class="token punctuation">-&gt;</span> <span class="token operator">!</span> <span class="token punctuation">{</span>
        <span class="token keyword">let</span> inner <span class="token operator">=</span> <span class="token keyword">self</span><span class="token punctuation">.</span><span class="token function">inner</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// &#x5728; idle &#x7EBF;&#x7A0B;&#x521A;&#x8FDB;&#x6765;&#x65F6;&#x7981;&#x7528;&#x5F02;&#x6B65;&#x4E2D;&#x65AD;</span>
        <span class="token function">disable_and_store</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token keyword">loop</span> <span class="token punctuation">{</span>
            <span class="token comment">// &#x5982;&#x679C;&#x4ECE;&#x7EBF;&#x7A0B;&#x6C60;&#x4E2D;&#x83B7;&#x53D6;&#x5230;&#x4E00;&#x4E2A;&#x53EF;&#x8FD0;&#x884C;&#x7EBF;&#x7A0B;</span>
            <span class="token keyword">if</span> <span class="token keyword">let</span> <span class="token class-name">Some</span><span class="token punctuation">(</span>thread<span class="token punctuation">)</span> <span class="token operator">=</span> inner<span class="token punctuation">.</span>pool<span class="token punctuation">.</span><span class="token function">acquire</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token comment">// &#x5C06;&#x81EA;&#x8EAB;&#x7684;&#x6B63;&#x5728;&#x8FD0;&#x884C;&#x7EBF;&#x7A0B;&#x8BBE;&#x7F6E;&#x4E3A;&#x521A;&#x521A;&#x83B7;&#x53D6;&#x5230;&#x7684;&#x7EBF;&#x7A0B;</span>
                inner<span class="token punctuation">.</span>current <span class="token operator">=</span> <span class="token class-name">Some</span><span class="token punctuation">(</span>thread<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token comment">// &#x4ECE;&#x6B63;&#x5728;&#x8FD0;&#x884C;&#x7684;&#x7EBF;&#x7A0B; idle &#x5207;&#x6362;&#x5230;&#x521A;&#x521A;&#x83B7;&#x53D6;&#x5230;&#x7684;&#x7EBF;&#x7A0B;</span>
                <span class="token macro property">println!</span><span class="token punctuation">(</span><span class="token string">&quot;\n&gt;&gt;&gt;&gt; will switch_to thread {} in idle_main!&quot;</span><span class="token punctuation">,</span> inner<span class="token punctuation">.</span>current<span class="token punctuation">.</span><span class="token function">as_mut</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">unwrap</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                inner<span class="token punctuation">.</span>idle<span class="token punctuation">.</span><span class="token function">switch_to</span><span class="token punctuation">(</span>
                    <span class="token operator">&amp;</span><span class="token keyword">mut</span> <span class="token operator">*</span>inner<span class="token punctuation">.</span>current<span class="token punctuation">.</span><span class="token function">as_mut</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">unwrap</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token number">1</span>
                <span class="token punctuation">)</span><span class="token punctuation">;</span>

                <span class="token comment">// &#x4E0A;&#x4E2A;&#x7EBF;&#x7A0B;&#x65F6;&#x95F4;&#x8017;&#x5C3D;&#xFF0C;&#x5207;&#x6362;&#x56DE;&#x8C03;&#x5EA6;&#x7EBF;&#x7A0B; idle</span>
                <span class="token macro property">println!</span><span class="token punctuation">(</span><span class="token string">&quot;&lt;&lt;&lt;&lt; switch_back to idle in idle_main!&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token comment">// &#x6B64;&#x65F6; current &#x8FD8;&#x4FDD;&#x5B58;&#x7740;&#x4E0A;&#x4E2A;&#x7EBF;&#x7A0B;</span>
                <span class="token keyword">let</span> <span class="token punctuation">(</span>tid<span class="token punctuation">,</span> thread<span class="token punctuation">)</span> <span class="token operator">=</span> inner<span class="token punctuation">.</span>current<span class="token punctuation">.</span><span class="token function">take</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">unwrap</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token comment">// &#x901A;&#x77E5;&#x7EBF;&#x7A0B;&#x6C60;&#x8FD9;&#x4E2A;&#x7EBF;&#x7A0B;&#x9700;&#x8981;&#x5C06;&#x8D44;&#x6E90;&#x4EA4;&#x8FD8;&#x51FA;&#x53BB;</span>
                inner<span class="token punctuation">.</span>pool<span class="token punctuation">.</span><span class="token function">retrieve</span><span class="token punctuation">(</span>tid<span class="token punctuation">,</span> thread<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token comment">// &#x5982;&#x679C;&#x73B0;&#x5728;&#x5E76;&#x65E0;&#x4EFB;&#x4F55;&#x53EF;&#x8FD0;&#x884C;&#x7EBF;&#x7A0B;</span>
            <span class="token keyword">else</span> <span class="token punctuation">{</span>
                <span class="token comment">// &#x6253;&#x5F00;&#x5F02;&#x6B65;&#x4E2D;&#x65AD;&#xFF0C;&#x5E76;&#x7B49;&#x5F85;&#x5F02;&#x6B65;&#x4E2D;&#x65AD;&#x7684;&#x5230;&#x6765;</span>
                <span class="token function">enable_and_wfi</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token comment">// &#x5F02;&#x6B65;&#x4E2D;&#x65AD;&#x5904;&#x7406;&#x8FD4;&#x56DE;&#x540E;&#xFF0C;&#x5173;&#x95ED;&#x5F02;&#x6B65;&#x4E2D;&#x65AD;</span>
                <span class="token function">disable_and_store</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5982;&#x679C;&#x73B0;&#x5728;&#x90FD;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x53EF;&#x8FD0;&#x884C;&#x7EBF;&#x7A0B;&#x4E86;&#xFF0C;&#x90A3;&#x5B9E;&#x9645;&#x4E0A;&#x6211;&#x4EEC;&#x4E5F;&#x4E0D;&#x4F1A;&#x8FDB;&#x884C;&#x4EFB;&#x4F55;&#x8C03;&#x5EA6;&#xFF0C;&#x6240;&#x4EE5;&#x5373;&#x4F7F;&#x9047;&#x5230;&#x4E86;&#x65F6;&#x949F;&#x4E2D;&#x65AD;&#x6211;&#x4EEC;&#x4E5F;&#x4E0D;&#x6015;&#x3002;&#x800C;&#x4E14;&#x6B64;&#x65F6;&#xFF0C;&#x8FDB;&#x5165;&#x4E2D;&#x65AD;&#x662F;&#x552F;&#x4E00;&#x53EF;&#x80FD;&#x7ED9;&#x6211;&#x4EEC;&#x63D0;&#x4F9B;&#x4E00;&#x4E9B;&#x65B0;&#x7684;&#x7EBF;&#x7A0B;&#x8FD0;&#x884C;&#x7684;&#x624B;&#x6BB5;&#x3002;</p>
<p>&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x6253;&#x5F00;&#x5E76;&#x9ED8;&#x9ED8;&#x7B49;&#x5F85;&#x4E2D;&#x65AD;&#x7684;&#x5230;&#x6765;&#x3002;&#x5F85;&#x4E2D;&#x65AD;&#x8FD4;&#x56DE;&#x540E;&#xFF0C;&#x8FD9;&#x65F6;&#x53EF;&#x80FD;&#x6709;&#x7EBF;&#x7A0B;&#x80FD;&#x591F;&#x8FD0;&#x884C;&#x4E86;&#xFF0C;&#x6211;&#x4EEC;&#x518D;&#x5173;&#x95ED;&#x4E2D;&#x65AD;&#xFF0C;&#x8FDB;&#x5165;&#x8C03;&#x5EA6;&#x5FAA;&#x73AF;&#x3002;</p>
<h3 id="&#x4E2D;&#x65AD;&#x5F15;&#x53D1;&#x8C03;&#x5EA6;">&#x4E2D;&#x65AD;&#x5F15;&#x53D1;&#x8C03;&#x5EA6;</h3>
<p>&#x63A5;&#x4E0B;&#x6765;&#xFF0C;&#x770B;&#x770B;&#x5982;&#x4F55;&#x501F;&#x7528;&#x65F6;&#x949F;&#x4E2D;&#x65AD;&#x8FDB;&#x884C;&#x5468;&#x671F;&#x6027;&#x8C03;&#x7528;<code>Processor</code>&#x7684;<code>tick</code>&#x65B9;&#x6CD5;&#xFF0C;&#x5B9E;&#x73B0;&#x5468;&#x671F;&#x6027;&#x8C03;&#x5EA6;&#x3002;&#x5F53;&#x4EA7;&#x751F;&#x65F6;&#x949F;&#x4E2D;&#x65AD;&#x65F6;&#xFF0C;&#x4E2D;&#x65AD;&#x5904;&#x7406;&#x51FD;&#x6570;<code>rust_trap</code>&#x4F1A;&#x8FDB;&#x4E00;&#x6B65;&#x8C03;&#x7528;<code>super_timer</code>&#x51FD;&#x6570;&#xFF0C;&#x5E76;&#x6700;&#x7EC8;&#x8C03;&#x7528;&#x5230;<code>Processor</code>&#x7684;<code>tick</code>&#x65B9;&#x6CD5;&#x3002;&#x4E0B;&#x9762;&#x662F;`tick``&#x65B9;&#x6CD5;&#x7684;&#x5177;&#x4F53;&#x5B9E;&#x73B0;&#x3002;</p>
<pre class="language-"><code class="lang-rust"><span class="token comment">// src/process/processor.rs</span>

<span class="token keyword">impl</span> <span class="token class-name">Processor</span> <span class="token punctuation">{</span>
    <span class="token keyword">pub</span> <span class="token keyword">fn</span> <span class="token function-definition function">tick</span><span class="token punctuation">(</span><span class="token operator">&amp;</span><span class="token keyword">self</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">let</span> inner <span class="token operator">=</span> <span class="token keyword">self</span><span class="token punctuation">.</span><span class="token function">inner</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token operator">!</span>inner<span class="token punctuation">.</span>current<span class="token punctuation">.</span><span class="token function">is_none</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token comment">// &#x5982;&#x679C;&#x5F53;&#x524D;&#x6709;&#x5728;&#x8FD0;&#x884C;&#x7EBF;&#x7A0B;</span>
            <span class="token keyword">if</span> inner<span class="token punctuation">.</span>pool<span class="token punctuation">.</span><span class="token function">tick</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token comment">// &#x5982;&#x679C;&#x8FD4;&#x56DE;true, &#x8868;&#x793A;&#x5F53;&#x524D;&#x8FD0;&#x884C;&#x7EBF;&#x7A0B;&#x65F6;&#x95F4;&#x8017;&#x5C3D;&#xFF0C;&#x9700;&#x8981;&#x88AB;&#x8C03;&#x5EA6;&#x51FA;&#x53BB;</span>

                <span class="token comment">// &#x6211;&#x4EEC;&#x8981;&#x8FDB;&#x5165; idle &#x7EBF;&#x7A0B;&#x4E86;&#xFF0C;&#x56E0;&#x6B64;&#x5FC5;&#x987B;&#x5173;&#x95ED;&#x5F02;&#x6B65;&#x4E2D;&#x65AD;</span>
                <span class="token comment">// &#x6211;&#x4EEC;&#x53EF;&#x6CA1;&#x4FDD;&#x8BC1; switch_to &#x524D;&#x540E; sstatus &#x5BC4;&#x5B58;&#x5668;&#x4E0D;&#x53D8;</span>
                <span class="token comment">// &#x56E0;&#x6B64;&#x5FC5;&#x987B;&#x624B;&#x52A8;&#x4FDD;&#x5B58;</span>
                <span class="token keyword">let</span> flags <span class="token operator">=</span> <span class="token function">disable_and_store</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

                <span class="token comment">// &#x5207;&#x6362;&#x5230; idle &#x7EBF;&#x7A0B;&#x8FDB;&#x884C;&#x8C03;&#x5EA6;</span>
                inner<span class="token punctuation">.</span>current
                    <span class="token punctuation">.</span><span class="token function">as_mut</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                    <span class="token punctuation">.</span><span class="token function">unwrap</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                    <span class="token punctuation">.</span><span class="token number">1</span>
                    <span class="token punctuation">.</span><span class="token function">switch_to</span><span class="token punctuation">(</span><span class="token operator">&amp;</span><span class="token keyword">mut</span> inner<span class="token punctuation">.</span>idle<span class="token punctuation">)</span><span class="token punctuation">;</span>

                <span class="token comment">// &#x4E4B;&#x540E;&#x67D0;&#x4E2A;&#x65F6;&#x5019;&#x53C8;&#x4ECE; idle &#x7EBF;&#x7A0B;&#x5207;&#x6362;&#x56DE;&#x6765;</span>
                <span class="token comment">// &#x6062;&#x590D; sstatus &#x5BC4;&#x5B58;&#x5668;&#x7EE7;&#x7EED;&#x4E2D;&#x65AD;&#x5904;&#x7406;</span>
                <span class="token function">restore</span><span class="token punctuation">(</span>flags<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x4ECE;&#x4E00;&#x4E2A;&#x88AB; idle &#x7EBF;&#x7A0B;&#x7BA1;&#x7406;&#x7684;&#x7EBF;&#x7A0B;&#x7684;&#x89D2;&#x5EA6;&#x6765;&#x770B;&#xFF0C;&#x4ECE;&#x8FDB;&#x5165;&#x65F6;&#x949F;&#x4E2D;&#x65AD;&#x5230;&#x53D1;&#x73B0;&#x81EA;&#x5DF1;&#x8981;&#x88AB;&#x8C03;&#x5EA6;&#x51FA;&#x53BB;&#xFF0C;&#x6574;&#x4E2A;&#x8FC7;&#x7A0B;&#x90FD;&#x8FD8;&#x662F;&#x8FD0;&#x884C;&#x5728;&#x8FD9;&#x4E2A;&#x7EBF;&#x7A0B;&#x81EA;&#x5DF1;&#x8EAB;&#x4E0A;&#x3002;&#x968F;&#x540E;&#x88AB;&#x5207;&#x6362;&#x5230; idle &#x7EBF;&#x7A0B;&#xFF0C;&#x53C8;&#x8FC7;&#x4E86;&#x4E00;&#x6BB5;&#x65F6;&#x95F4;&#x4E4B;&#x540E;&#x4ECE; idle &#x7EBF;&#x7A0B;&#x5207;&#x6362;&#x56DE;&#x6765;&#xFF0C;&#x7EE7;&#x7EED;&#x8FDB;&#x884C;&#x4E2D;&#x65AD;&#x5904;&#x7406;&#x3002;</p>
<p>&#x5F53;&#x7136; idle &#x7EBF;&#x7A0B;&#x4E5F;&#x4F1A;&#x8FDB;&#x5165;&#x65F6;&#x949F;&#x4E2D;&#x65AD;&#xFF0C;&#x4F46;&#x8FD9;&#x4EC5;&#x9650;&#x4E8E;&#x5F53;&#x524D;&#x65E0;&#x4EFB;&#x4F55;&#x5176;&#x4ED6;&#x53EF;&#x8FD0;&#x884C;&#x7EBF;&#x7A0B;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x3002;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x53D1;&#x73B0;&#xFF0C;&#x8FDB;&#x5165;&#x8FD9;&#x4E2A;&#x65F6;&#x949F;&#x4E2D;&#x65AD;&#x5E76;&#x4E0D;&#x5F71;&#x54CD; idle &#x7EBF;&#x7A0B;&#x6B63;&#x5E38;&#x8FD0;&#x884C;&#x3002;</p>
<h3 id="&#x7EBF;&#x7A0B;&#x9000;&#x51FA;">&#x7EBF;&#x7A0B;&#x9000;&#x51FA;</h3>
<p>&#x63A5;&#x4E0B;&#x6765;&#xFF0C;&#x4E00;&#x4E2A;&#x7EBF;&#x7A0B;&#x5982;&#x4F55;&#x901A;&#x8FC7; Processor &#x5BA3;&#x79F0;&#x81EA;&#x5DF1;&#x8FD0;&#x884C;&#x7ED3;&#x675F;&#x5E76;&#x9000;&#x51FA;&#x3002;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x4E5F;&#x662F;&#x5728;&#x8BE5;&#x7EBF;&#x7A0B;&#x81EA;&#x8EAB;&#x4E0A;&#x8FD0;&#x884C;&#x7684;&#x3002;</p>
<pre class="language-"><code class="lang-rust"><span class="token comment">// src/process/processor.rs</span>

<span class="token keyword">impl</span> <span class="token class-name">Processor</span> <span class="token punctuation">{</span>
    <span class="token keyword">pub</span> <span class="token keyword">fn</span> <span class="token function-definition function">exit</span><span class="token punctuation">(</span><span class="token operator">&amp;</span><span class="token keyword">self</span><span class="token punctuation">,</span> code<span class="token punctuation">:</span> <span class="token keyword">usize</span><span class="token punctuation">)</span> <span class="token punctuation">-&gt;</span> <span class="token operator">!</span> <span class="token punctuation">{</span>
        <span class="token comment">// &#x7531;&#x4E8E;&#x8981;&#x5207;&#x6362;&#x5230; idle &#x7EBF;&#x7A0B;&#xFF0C;&#x5FC5;&#x987B;&#x5148;&#x5173;&#x95ED;&#x65F6;&#x949F;&#x4E2D;&#x65AD;</span>
        <span class="token function">disable_and_store</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// &#x7531;&#x4E8E;&#x81EA;&#x5DF1;&#x6B63;&#x5728;&#x6267;&#x884C;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x83B7;&#x53D6;&#x81EA;&#x8EAB;&#x7684; tid</span>
        <span class="token keyword">let</span> inner <span class="token operator">=</span> <span class="token keyword">self</span><span class="token punctuation">.</span><span class="token function">inner</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">let</span> tid <span class="token operator">=</span> inner<span class="token punctuation">.</span>current<span class="token punctuation">.</span><span class="token function">as_ref</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">unwrap</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token number">0</span><span class="token punctuation">;</span>

        <span class="token comment">// &#x901A;&#x77E5;&#x7EBF;&#x7A0B;&#x6C60;&#x8FD9;&#x4E2A;&#x7EBF;&#x7A0B;&#x9000;&#x51FA;&#x5566;&#xFF01;</span>
        inner<span class="token punctuation">.</span>pool<span class="token punctuation">.</span><span class="token function">exit</span><span class="token punctuation">(</span>tid<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token macro property">println!</span><span class="token punctuation">(</span><span class="token string">&quot;thread {} exited, exit code = {}&quot;</span><span class="token punctuation">,</span> tid<span class="token punctuation">,</span> code<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// &#x5207;&#x6362;&#x5230; idle &#x7EBF;&#x7A0B;&#x51B3;&#x5B9A;&#x4E0B;&#x4E00;&#x4E2A;&#x8FD0;&#x884C;&#x54EA;&#x4E2A;&#x7EBF;&#x7A0B;</span>
        inner<span class="token punctuation">.</span>current
            <span class="token punctuation">.</span><span class="token function">as_mut</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">unwrap</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token number">1</span>
            <span class="token punctuation">.</span><span class="token function">switch_to</span><span class="token punctuation">(</span><span class="token operator">&amp;</span><span class="token keyword">mut</span> inner<span class="token punctuation">.</span>idle<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token keyword">loop</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token comment">// src/process/mod.rs</span>

<span class="token keyword">pub</span> <span class="token keyword">fn</span> <span class="token function-definition function">exit</span><span class="token punctuation">(</span>code<span class="token punctuation">:</span> <span class="token keyword">usize</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token constant">CPU</span><span class="token punctuation">.</span><span class="token function">exit</span><span class="token punctuation">(</span>code<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x81F3;&#x6B64;&#x6211;&#x4EEC;&#x8BF4;&#x660E;&#x4E86;&#x8C03;&#x5EA6;&#x7EBF;&#x7A0B; idle &#x4EE5;&#x53CA;&#x8C03;&#x5EA6;&#x5355;&#x5143; Processor &#x3002;&#x4F46;&#x6211;&#x4EEC;&#x4E4B;&#x524D;&#x8FD8;&#x6316;&#x4E86;&#x4E00;&#x4E2A;&#x5751;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x4E0A;&#x4E00;&#x8282;&#x4E2D;&#xFF0C;&#x8C03;&#x5EA6;&#x7B97;&#x6CD5;&#x6211;&#x4EEC;&#x53EA;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E2A;&#x63A5;&#x53E3;&#x4F46;&#x5E76;&#x672A;&#x63D0;&#x4F9B;&#x5177;&#x4F53;&#x5B9E;&#x73B0;&#x3002;&#x4E0B;&#x4E00;&#x8282;&#x6211;&#x4EEC;&#x5C31;&#x6765;&#x4ECB;&#x7ECD;&#x4E00;&#x79CD;&#x6700;&#x7B80;&#x5355;&#x7684;&#x8C03;&#x5EA6;&#x7B97;&#x6CD5;&#x5B9E;&#x73B0;&#x3002;</p>
<p><div id="page-footer" class="localized-footer"><hr><p><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css"></p>
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
  var gitalk = new Gitalk({
    clientID: "ab871063a9fa7f1da571",
    clientSecret: "4760b384e3e452d2241d859cfa6a7da21a8729ec",
    repo: "rCore_tutorial_doc",
    owner: "rcore-os",
    admin: [
      "chyyuu",
      "xyongcn",
      "wangrunji0408",
      "xy-plus",
      "PanQL",
      "wyfcyx",
      "equation314"
    ],
    id: location.pathname,
    distractionFreeMode: false
  });
  gitalk.render("gitalk-container");
</script>
</div></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="part1.html" class="navigation navigation-prev " aria-label="Previous page: 线程池与线程管理">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="part3.html" class="navigation navigation-next " aria-label="Next page: 线程调度之 Round Robin 算法">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"内核调度线程 idle","level":"1.9.2","depth":2,"next":{"title":"线程调度之 Round Robin 算法","level":"1.9.3","depth":2,"path":"chapter7/part3.md","ref":"chapter7/part3.md","articles":[]},"previous":{"title":"线程池与线程管理","level":"1.9.1","depth":2,"path":"chapter7/part1.md","ref":"chapter7/part1.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["hide-element","chapter-fold","katex","alerts","emphasize","-highlight","prism","localized-footer","mermaid-gb3"],"pluginsConfig":{"chapter-fold":{},"prism":{"css":["prismjs/themes/prism-tomorrow.css"]},"emphasize":{},"search":{},"localized-footer":{"filename":"extensions/comment/gitalk.html","hline":"true"},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"hide-element":{"elements":[".gitbook-link"]},"katex":{},"fontsettings":{"theme":"white","family":"sans","size":2},"mermaid-gb3":{},"alerts":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"chapter7/part2.md","mtime":"2020-09-09T11:31:56.899Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-09-10T06:57:01.716Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-alerts/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    <script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>

